package org.je.cons;

import java.net.URL;
import java.net.URLDecoder;

import org.je.log.JLog;
import org.je.ufo.PUtil;

/**
 * @author fanyifeng 2012-8-31 下午1:55:16
 */
public class ClassPath
{
	private static String	class_path	= "/";

	static {
		URL url = ClassPath.class.getResource("/");
		if (url != null) {
			init(url.getPath());
		}
	}

	public static String get() {
		if (class_path == null)
			throw new NullPointerException("cant-get-classpath-root");
		return class_path;
	}

	private static void init(String url) {
		try {
			class_path = URLDecoder.decode(PUtil.format(url), JCons.enc().os_charset);
		} catch (Throwable ex) {
			JLog.error(ex);
			ex.printStackTrace();
		}
	}
}
